module.exports = (sequelize, DataTypes) => {
  const PushRecord = sequelize.define('PushRecord', {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true
    },
    userId: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: '关联用户ID'
    },
    subscriptionId: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: '关联订阅ID'
    },
    pushType: {
      type: DataTypes.ENUM('weather', 'traffic', 'custom'),
      allowNull: false,
      comment: '推送类型'
    },
    content: {
      type: DataTypes.TEXT,
      allowNull: false,
      comment: '推送内容'
    },
    pushTime: {
      type: DataTypes.DATE,
      allowNull: false,
      comment: '推送时间'
    },
    status: {
      type: DataTypes.ENUM('pending', 'success', 'failed'),
      defaultValue: 'pending',
      comment: '推送状态'
    },
    errorMsg: {
      type: DataTypes.TEXT,
      comment: '错误信息'
    }
  }, {
    tableName: 'push_records',
    timestamps: true,
    comment: '推送记录表'
  });

  return PushRecord;
};